package org.codert.web;

import com.alibaba.nacos.api.annotation.NacosInjected;
import com.alibaba.nacos.api.config.annotation.NacosValue;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingService;
import com.alibaba.nacos.api.naming.pojo.Instance;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/test")
public class TestController {
    @NacosValue(value = "${testValue:没设置呢}", autoRefreshed = true)
    private String value;
    @NacosInjected
    private NamingService namingService;

    @GetMapping
    public String getValue() {
        return value;
    }

    @GetMapping("/discovery")
    public Object getDiscovery() throws NacosException {
        List<Instance> allInstances = namingService.getAllInstances("boot-nacos");
        return "success...";
    }
}
